<template>
  <el-radio-group v-model="userType.val" @change="choosed">
    <!-- <el-radio label="公证员"></el-radio>
    <el-radio label="用证员"></el-radio> -->
    <template v-for="item in Object.keys(userTypeList)" :key="item">
      <el-radio 
        v-if="userTypeList[item][purpose]"
        :label="userTypeList[item].value">
        {{ userTypeList[item].label }}
      </el-radio>
    </template>
  </el-radio-group>
</template>

<script lang="ts">
import { defineComponent, reactive, computed } from 'vue';
import { USER_TYPES } from '@/config/index'
/**
 * 用户组件封装
 * @Author yuanyexu
 * @Date 2021-08-19
 */
export default defineComponent({
  name: 'CompanyChoose',
  props: ['defaultVal', 'purpose'],
  emits: ['change'],
  setup(props, ctx) {
    const userType = reactive({
      val: '',
      list: []
    });
    // 设置初始值
    userType.val = props.defaultVal;
    const userTypeList = computed(() => {
      return USER_TYPES;
    })
    const purpose = props.purpose;
    const choosed = (data:any) => {
      ctx.emit('change', data);
    };
    return {
      userTypeList,
      userType,
      purpose,
      choosed
    };
  },
});
</script>
